<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
%>

<!--  2010-07-03 教师任课安排  修改 2010-07-16 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
		<title>教师任课安排</title>
		<link href="<%=path %>/css/index_css.css" rel="stylesheet" type="text/css" />
		<script language="javascript" src="<%=path %>/js/syAjax.js"></script>
		<script src="<%=path%>/js/resizeIframe.js" type="text/javascript"></script>
		<script src="<%=path%>/dwr/engine.js"></script>
	    <script src="<%=path%>/dwr/util.js"></script>
	    <script src="<%=path%>/dwr/interface/shiyueDwr.js"></script>
		<script type="text/javascript">	
	var objectTD;
	var objectHIDDENID;
	var orgId;
	function giveParamArr(){
		return document.getElementById(objectHIDDENID).value;
	}

      //显示遮罩
      function displayModuleDiv(){
		document.getElementById("items").style.display = "";	
		resizeIframe();
	}
	
	//关闭div
	function closeDIV(){
		document.getElementById("items").style.display = "none";
	}
	function doChooseUser(returnStr){
	//原版内容
		if(returnStr==undefined){
			return;
		}	
		if(returnStr!=null && returnStr!=""){
			var UserArr = returnStr.substring(0,returnStr.length-1).split(",");
			var UserNameStr="";
			var pppValue="";
			for(var i=0;i<UserArr.length;i++){
				var user=UserArr[i];
				var sonArr=user.split("_");
				pppValue+=sonArr[0]+",";
				UserNameStr+=sonArr[1]+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>";
			}
			if(UserNameStr!=""){
				UserNameStr+="<input id=\""+ objectHIDDENID +"\" type=\"hidden\" value=\""+pppValue+"\"/>";													
				document.getElementById("div"+objectTD).innerHTML=UserNameStr;
			}
		}else{
			document.getElementById("div"+objectTD).innerHTML="<input id=\""+objectHIDDENID+"\" type=\"hidden\" value=\"\"/>";
		}
		closeDIV();
	}
		function showModel2(classId,courseId){
			 //判断是不是当前年度
			orgId=classId+"#"+courseId;
			objectHIDDENID="ppp"+classId+""+courseId;
			objectTD=classId+""+courseId;
	        if(document.getElementById('year').value=='${applicationScope.currentYear}')
			{
				document.getElementById("selectUserIframe").src="<%=path%>/toSelectTeacherorganizationAction.action?gradeId=${GRADEID}&years=${applicationScope.currentYear}&role.roleId=member&actionURL=saveUserClassRelationorganizationAction.action&t="+new Date();
				displayModuleDiv();
			}else{
	      		alert("不是当前年度，不能进行此操作！");
	      	}
		}
      
        function tdClick(url)
        {
          window.location.href=url;
        }
        
        function change(year)
        {
          window.location.href='getAllCourseByGradeIdGradeAndClassAction.action?year='+year;
        }
        
        function changeGrade(gradeId)
        {
          window.location.href='getAllCourseByGradeIdGradeAndClassAction.action?grade.gradeId='+gradeId+'&year='+document.getElementById('year').value;
        }
        
	    function getAllYearCallBack(yearMap) {
	     DWRUtil.addOptions("year", yearMap);
	     if('${year}'!="")
	   	{
	   	  document.getElementById('year').value="${year}";
	   	}
	   	else if('${currentYear}'!="")
	   	{
	   	  document.getElementById('year').value="${currentYear}";
	   	}
	   	shiyueDwr.findAllGradeByYear(document.getElementById('year').value,1,findGradeCallBack);
	    }
     
	     function findGradeCallBack(orgMap) {
			 DWRUtil.removeAllOptions("grade");	
		     DWRUtil.addOptions("grade", orgMap);
		      if('${GRADEID}'!='')
		      {
		        document.getElementById("grade").value="${GRADEID}";
		      }
	    }
	     
	    function load()
	    {
	    	shiyueDwr.getAllYear(getAllYearCallBack);
	    	resizeIframe();
	    	parent.location.hash="top";
	    	new Anim.DD($("items"), $("title"));
			$("items").style.left = "50px";
			$("items").style.top = "100px";
	    }
	  
	  function excelImport(){
	  	 document.getElementById("chooseGradeId").value=document.getElementById("grade").value;
	  	 document.excelForm.submit();
	  }
	  
    </script>
  </head>
  <body onload="load();">
  <div id="contentDIV" style="position:absolute;width:100%; padding:5px; background-color:#ffffff;z-index:1;">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="2" align="left" class="f_5">岗位安排</td>
  </tr>
  <tr>
    <td height="1" colspan="2" bgcolor="#9DD12E"></td>
  </tr>
  <tr>
    <td colspan="2" align="left" valign="top">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2" align="left"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="left" valign="bottom" background="<%=path %>/images/sywesp_24.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          
          <tr>
            <td width="80" align="left"><table width="80" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="1" align="left" valign="bottom" bgcolor="#CBCBCB"></td>
                <td align="center" background="<%=path %>/images/sywesp_25.gif" class="f_9">任课安排</td>
                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"></td>
              </tr>
            </table></td>
            <td width="90" align="left"><table width="90" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="center" background="<%=path %>/images/sywesp_18.gif" class="f_6" onclick="tdClick('classLeaderUserAction.action?year=${currentYear }');" style="cursor:pointer;">班主任安排</td>
                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"></td>
              </tr>
            </table></td>
            <td width="100" align="left"><table width="100" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="center" background="<%=path %>/images/sywesp_18.gif" class="f_6" onclick="tdClick('gradeSubjectTeamLeaderorganizationAction.action?role.roleId=bkzz&years=${currentYear }');" style="cursor:pointer;">备课组长安排</td>

                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"></td>
              </tr>
            </table></td>
            <td width="100" align="left"><table width="100" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="center" background="<%=path %>/images/sywesp_18.gif" class="f_6" onclick="tdClick('subjectTeamLeaderorganizationAction.action?role.roleId=jyzz&year.name=${currentYear }');" style="cursor:pointer;">教研组长安排</td>

                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"></td>
              </tr>
            </table></td>
            <td width="100" align="left"><table width="100" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="center" background="<%=path %>/images/sywesp_18.gif" class="f_6" onclick="tdClick('toGradeTeamLeaderGradeAndClassAction.action?year=${currentYear }&role.roleId=njzz');" style="cursor:pointer;">年级组长安排</td>
                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"></td>
              </tr>
            </table></td>
            <td width="110" align="left"><table width="110" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="center" background="<%=path %>/images/sywesp_18.gif" class="f_6" onclick="tdClick('departmentLeaderorganizationAction.action?role.roleId=bmfzr&year.name=${currentYear }');" style="cursor:pointer;">部门负责人安排</td>
                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"><br></td>
              </tr>
            </table></td>
            <td align="left">&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      
      <tr>
        <td align="left" valign="top" class="tb_8 border_2" width="100%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="25" align="left" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="left">按年度查询：
                  <label>
                  <select name="select2" id="year" onchange="change(this.value);">
                  </select>
	                 	 年级：
	              <select id="grade" onchange="changeGrade(this.value);">
	                 <option value="">请选择</option>
	              </select>
                  </label>
                  &nbsp;&nbsp;&nbsp;&nbsp;<img src="<%=path %>/images/disk_icon_excel.gif" width="16" /><a href="javascript:excelImport();">从excel导入任课安排信息</a>
                  <br/></td>
                  <td align="right" valign="top"><a href="<%=path %>/getRKClassByUserIdAndcourseIdGradeAndClassAction.action?year=${applicationScope.currentYear}">按人员设置</a>&nbsp;</td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td align="left" valign="top" width="100%">
            <div style="width:100%;overflow-x:auto;">
            <table width="" border="0" cellpadding="0" cellspacing="1" bgcolor="#DCDCDC">
              <tr>
                <td width="10%" height="30" align="center" bgcolor="#DBE9F6" class="f_4">班级</td>
                <c:set value="1" var="i" />
                <c:forEach items="${requestScope.courseList}" var="course">
                  <td align="center" bgcolor="#DBE9F6" class="f_4">${course.name }</td>
                  <c:set value="${i+1}" var="i" />
                </c:forEach>
              </tr>
              <c:choose>
                <c:when test="${! empty requestScope.classList}">
                  <c:forEach items="${requestScope.classList}" var="cla">
	                <tr>
	                  <td height="30" bgcolor="#FFFFFF" class="f_4" nowrap="nowrap" align="center"> &nbsp;${cla.name }</td>
	                  <c:forEach items="${requestScope.courseList}" var="course">
	                     <c:if test="${! empty requestScope.map}">
	                       <c:set value="${cla.classId}${course.courseId }" var="classCourse" />
	                    	<td width="${100/i }%" align="center" bgcolor="#FFFFFF" nowrap="nowrap" onclick="showModel2('${cla.classId }','${course.courseId }');" onmouseover="this.style.backgroundColor='#e4f5ff'" onmouseout="this.style.backgroundColor=''" style="cursor:pointer;">
                     	 	 <c:if test="${! empty map[classCourse]}">
                     	 	    <div id="div${cla.classId }${course.courseId }">
                     	 		<input type="hidden" id="ppp${cla.classId }${course.courseId }" value="" />
                     	 		<c:forEach items="${map[classCourse]}" var="user">
                     	 		${user.name}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>
                     	 		<c:set var="ych" value="<script>document.getElementById('ppp${cla.classId }${course.courseId }').value+='${user.userId}'+',';</script>" scope="page"/>
                     	 	 	<%
                     	 	 	out.write((String)pageContext.getAttribute("ych"));
                     	 	 	 %>
                     	 	 	</c:forEach>
                     	 	 	</div>
                     	 	 </c:if>
	                     	 <c:if test="${empty map[classCourse]}">
	                     	 	<div id="div${cla.classId }${course.courseId }">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="hidden" id="ppp${cla.classId }${course.courseId }" value="" /></div>
	                     	 </c:if>
	                    	</td>
	                     </c:if>
	                     <c:if test="${empty requestScope.map}">
	                     <td bgcolor="#FFFFFF" onclick="showModel2('${cla.classId }','${course.courseId }');" onmouseover="this.style.backgroundColor='#e4f5ff'" onmouseout="this.style.backgroundColor=''" style="cursor:pointer;">
	                     <div id="div${cla.classId }${course.courseId }">
	                     <input type="hidden" id="ppp${cla.classId }${course.courseId }" value="" />
	                     &nbsp;
	                     </div>
	                     </td>
	                     </c:if>
	                   </c:forEach>
	                </tr>
	              </c:forEach>
                </c:when>
                <c:otherwise><tr><td bgcolor="#FFFFFF" align="center" height="30" colspan="${i }"><font color="#CCCCCC">无班级信息</font></td></tr></c:otherwise>
              </c:choose>
            </table>
            </div>
             </td>
          </tr>
        </table>
          </td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table></td>
  </tr>
</table>
</div>
<div id="items" style="position: absolute; width: 730px;height:600px; top:100px; left:200px; padding-bottom:8px; background-color:#ECF7FD;z-index:10; border:3px solid #3A6EA5; display: none;" >
	<div style="width:100%;top:100px;left:200px;" id="title">
		<table border="0" width="100%" cellpadding="0" cellspacing="0" align="center" bgcolor="#3A6EA5">
						<tr style=" height: 30px;">
		<td>&nbsp;&nbsp;<font color='#FFFFFF'>请选择教师</font></td>
		<td align="right"><a href="javascript:closeDIV();" style="text-decoration: none;"><span style="color: #000000; font-size:;">[关闭]</span></a></td>
						</tr>
		</table>
	</div>
	<div style="width:100%;top:100px;left:200px;height: 100%">
	<iframe name="selectUserIframe" id="selectUserIframe" src="" style="width:100%;height: 100%" align="middle"  frameborder="0"></iframe>   
	</div>	
</div>
<form name="excelForm" action="<%=path %>/toImportCourseExcelGradeAndClassAction.action" method="post">
<input type="hidden" id="excelbackURL" name="backURL" value="<%=path %>/getAllCourseByGradeIdGradeAndClassAction.action?year=${applicationScope.currentYear}"></input>
<input type="hidden" id="chooseGradeId" name="chooseGradeId" value="" />
</form>
  </body>
</html>
